#!/bin/bash
# 使用前需建立网桥docker:172.18.0.0/16

# 获取默认配置文件并覆盖
if [ ! -d ./conf ]; then
  mkdir ./conf
fi

if [ ! -f ./conf/zoo.cfg ]; then
  docker run -itd --name zookeeper zookeeper
  docker cp zookeeper:/conf/zoo.cfg ./conf/zoo.cfg
  docker stop zookeeper
  docker rm zookeeper
fi

# 运行容器
docker run -itd --name zookeeper \
	--net=docker --ip=172.18.2.1 \
	--restart=always \
	-p 2181:2181 \
	-v ./data:/data \
	-v ./datalog:/datalog \
	-v ./logs:/logs \
	-v ./conf/zoo.cfg:/conf/zoo.cfg \
	-e ZOO_LOG4J_PROP="INFO,ROLLINGFILE" \
	zookeeper